package cst.neu.yuejian_31.fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

import cst.neu.yuejian_31.R;
import cst.neu.yuejian_31.adapter.NewActivityAdapter;
import cst.neu.yuejian_31.adapter.PopularityAdapter;
import cst.neu.yuejian_31.bean.ClubBean;
import cst.neu.yuejian_31.iface.NewActivityListener;
import cst.neu.yuejian_31.iface.PopularityListener;
import cst.neu.yuejian_31.model.NewActivityModel;
import cst.neu.yuejian_31.model.PopularityModel;

public class DistanceFragment extends BaseFragment{
    private RecyclerView recyclerView;
    private RecyclerView.LayoutManager layoutManager;
    private NewActivityAdapter newActivityAdapter;
    private List<ClubBean> list=null;
    private View view=null;
    private Context context;
    private TextView clubname;


    NewActivityListener newActivityListener=new NewActivityListener() {
        @Override
        public void onResponse(List<ClubBean> list) {
            list=list;
            newActivityAdapter.setList(list);
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(context,msg, Toast.LENGTH_SHORT).show();
        }
    };





    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view= inflater.inflate(R.layout.fragment_distance, container, false);
        NewActivityModel newActivityModel=new NewActivityModel();
        newActivityModel.getClubList(newActivityListener);
        init();
        return view;

    }


    private void init() {
       context=this.getActivity();
        recyclerView= (RecyclerView) view.findViewById(R.id.recyclerView_distance);
        layoutManager=new LinearLayoutManager(context);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setHasFixedSize(true);
        newActivityAdapter=new NewActivityAdapter(context);
        recyclerView.setAdapter(newActivityAdapter);
// 设置Item之间间隔样式
        recyclerView .addItemDecoration(new DividerItemDecoration(context,LinearLayoutManager.VERTICAL));

    }


}
